package com.mi.fastbird.common.util.project;

/**
 * 已知异常抛出
 *
 * @author 王永吉
 * @date 2020/02/06
 */
public class MiException extends RuntimeException {
    /**
     * 统一异常处理信息返回
     */
    public SRS response() {
        if (haveResMsg) {
            return SRS.byError(resMsg);
        } else {
            return SRS.byError(code, message);
        }
    }

    public ResMsg resMsg = ResMsg.ERROR;
    public Boolean haveResMsg;

    MiException(ResMsg miResponse) {
        this.resMsg = miResponse;
        this.haveResMsg = true;
    }

    //
    public Integer code = 500;
    public Boolean success = false;
    public String message = "";

    MiException(String message) {
        this.haveResMsg = false;
        this.message = message;
    }

    MiException(Integer code, String message) {
        this.haveResMsg = false;
        this.code = code;
        this.message = message;
    }

}
